package cn.tedu.spring;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class SpringRunner {

    public static void main(String[] args) {
        System.out.println("1. 加载Spring配置……");
        AnnotationConfigApplicationContext ac
                = new AnnotationConfigApplicationContext(SpringConfig.class);
        System.out.println("1. 已经完成加载Spring配置！");
        System.out.println();

        System.out.println("2. 从Spring容器中获取对象……");
        Object userMapper1 = ac.getBean("userMapper");
        Object userMapper2 = ac.getBean("userMapper");
        Object userMapper3 = ac.getBean("userMapper");
        System.out.println("2. 已经完成从Spring容器中获取对象！");
        System.out.println();

        System.out.println("3. 测试……");
        System.out.println(userMapper1);
        System.out.println(userMapper2);
        System.out.println(userMapper3);
        System.out.println("3. 已经完成测试！");
        System.out.println();

        System.out.println("4. 关闭……");
        ac.close();
        System.out.println("4. 已经完成关闭！");
    }

}
